<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');

// 为 News 控制器添加路由
$routes->get('news', 'News::index');
$routes->match(['get', 'post'], 'news/create', 'News::create'); // <-- 新增这一行
$routes->get('news/delete/(:num)', 'News::delete/$1');  // 新增删除路由
$routes->get('news/(:segment)', 'News::view/$1');

// 为 Pages 控制器添加路由
$routes->get('(:any)', 'Pages::view/$1');